from urllib import request
from urllib import parse
import json
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=https://www.baidu.com/link'
Form_Data = {}
Form_Data["type"]='AUTO'
Form_Data['i'] = 'Apple'
Form_Data['doctype'] = 'json'
Form_Data['xmlVersion'] = '1.8'
Form_Data['keyfrom'] = 'fanyi.web'
Form_Data['ue'] = 'ue:UTF-8'
Form_Data['action'] = 'FY_BY_CLICKBUTTON'
data = parse.urlencode(Form_Data).encode('utf-8')
response = request.urlopen(url,data)
html = response.read().decode('utf-8','ignore')
#print(html)
translate_results = json.loads(html)
translate_results = translate_results['translateResult'][0][0]['tgt']
print("翻译的结果是：%s" % translate_results)
#print(response.geturl() )
#print(response.info())
rr = request.Request("http://www.baidu.com")
 
print(rr.get_full_url())